from fastmcp import FastMCP

# Create an MCP server
mcp = FastMCP("Calculator Server")

@mcp.tool()
def add(a: float, b: float) -> float:
    """Calculate the sum of two numbers"""
    return a + b

@mcp.tool()
def subtract(a: float, b: float) -> float:
    """Calculate the difference between two numbers"""
    return a - b

@mcp.tool()
def multiply(a: float, b: float) -> float:
    """Calculate the product of two numbers"""
    return a * b

@mcp.tool()
def divide(a: float, b: float) -> float:
    """Calculate the quotient of two numbers"""
    if b == 0:
        raise ValueError("Division by zero is not allowed")
    return a / b

@mcp.resource("calculator://{operation}")
def get_calculator_resource(operation: str) -> str:
    """Get a calculator resource for the specified operation"""
    return f"Calculator resource for {operation} operation." 

if __name__ == "__main__":
    mcp.run(transport="stdio")